package com.ruoyi.logistic.service.impl;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.logistic.domain.NetworkName;
import com.ruoyi.logistic.domain.SysUserInfo;
import com.ruoyi.logistic.domain.SysUserRelation;
import com.ruoyi.logistic.mapper.NetworkNameMapper;
import com.ruoyi.logistic.mapper.SysUserInfoMapper;
import com.ruoyi.logistic.mapper.SysUserRelationMapper;
import com.ruoyi.logistic.service.SysUserRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SysUserRelationServiceImpl implements SysUserRelationService {
    @Autowired
    private SysUserRelationMapper sysUserRelationMapper;
    @Autowired
    private SysUserInfoMapper userInfoMapper;
    @Autowired
    private NetworkNameMapper networkNameMapper;
    @Override
    public Boolean relationAccount(SysUserRelation sysUserRelation) {
        sysUserRelation.setSysParentUserId(SecurityUtils.getUserId());
        return sysUserRelationMapper.insert(sysUserRelation);
    }

    @Override
    public SysUserInfo findById() {
        SysUserInfo info = userInfoMapper.selectUserInfo(SecurityUtils.getUserId());
        info.setNetworkName(networkNameMapper.selectNameById(String.valueOf(info.getDeptId())));
        info.setDeptInfo(networkNameMapper.selectNameById(String.valueOf(info.getDeptId())));
        return info;
    }
}
